require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsHeroCrystalHandler={};
local this = RedDotsHeroCrystalHandler;

local crystalConfig = nil;

function RedDotsHeroCrystalHandler.init()
    CloseEvent(Config.EventType.Fresh_Crystal,this.update);
    ListenEvent(Config.EventType.Fresh_Crystal,this.update);

    if crystalConfig == nil then
        crystalConfig = G.dataTable["t_crystal"];
    end
    return this;
end


--参数 无
function RedDotsHeroCrystalHandler.getFlag(...)
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.HandBook,false) then
        local info = logicMgr.HeroManager.getCrystalInfo();
        local cg = crystalConfig[tostring(info.level)];
        if cg~=nil and cg.f_Value<=info.exp then
            return Config.RedDotsFlagState.Needful;
        end
    end
    return Config.RedDotsFlagState.None;
end

function RedDotsHeroCrystalHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.HeroCrystal);
end